from basic import *
import layerClassification
import copy


def note_solution(S, C1, C2, N):
    _C1 = copy.deepcopy(C1)
    _C2 = copy.deepcopy(C2)
    S.append([_C1, _C2])
    N = N + 1
    return S


def select_min(C1, C2):
    min_x = C2[0]
    min_d = internal_classes(C1, min_x)
    for x in C2:
        temp = internal_classes(C1, x)
        if temp < min_d:
            min_d = temp
            min_x = x
    return min_x


def update(min_x, C1, C2):
    C1.append(min_x)
    C2.remove(min_x)
    return [C1, C2]


def process(classification):
    N = 0
    S = []
    M = []
    C1 = classification[0]
    C2 = classification[1]
    while True:
        note_solution(S, C1, C2, N)
        min_x = select_min(C1, C2)
        M.append(min_x)
        update(min_x, C1, C2)
        if len(C2) == 0:
            break
    del(S[0])
    return S, M


if __name__ == '__main__':
    a = ['2333333333', '天若有情天亦老', '3.14159',
         'YvesX', '4444', 'To be or not to be']
    b = ['阿里巴巴', '阿童木', '阿里爷爷', '阿凡提', '阿里里里']
    d = ['肖华宇', '李亚泽', '江伟杰', '王晓涛', '陈丁']
    print("Input:")
    print(d)
    print("Classification:")
    pre_res = layerClassification.process(d)
    print(pre_res[0])
    print(pre_res[1])
    print("Solutions:")
    res = process(pre_res)
    print(res)
    print(res[0][0])